//
//  CompanyTableViewController.m
//  GoodWayClient
//
//  Created by HuiDong on 15/12/3.
//  Copyright © 2015年 HuiDong. All rights reserved.
//

#import "CompanyTableViewController.h"
#import "CompanyTableViewCell.h"

@interface CompanyTableViewController ()

@property (nonatomic, strong)NSArray *array;

@end

@implementation CompanyTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

//懒加载
- (NSArray *)array
{
    if (!_array) {
        _array = @[@{@"image":@"company",@"content":@"南京市区域公司"},@{@"image":@"comiphone",@"content":@"电话：15365083329"},@{@"image":@"comaddress",@"content":@"地址：珠江路88号新世界中心B座3912室"},@{@"image":@"newevent",@"content":@"查看最新动态"},@{@"image":@"point",@"content":@"查看安装点"}];
    }
    return _array;
}

//数据源方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return 1;
    }else if (section == 1)
    {
        return 2;
    }else
    {
        return 2;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        CompanyTableViewCell *cell = [CompanyTableViewCell CompanyWithTableView:tableView];
        cell.dic = self.array[indexPath.row];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell;
    }else if (indexPath.section == 1)
    {
        CompanyTableViewCell *cell = [CompanyTableViewCell CompanyWithTableView:tableView];
        cell.dic = self.array[indexPath.row + [self tableView:tableView numberOfRowsInSection:0]];
        return cell;
    }else
    {
        CompanyTableViewCell *cell = [CompanyTableViewCell CompanyWithTableView:tableView];
        NSInteger b = indexPath.row + [self tableView:tableView numberOfRowsInSection:0] + [self tableView:tableView numberOfRowsInSection:1];
        cell.dic = self.array[b];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell;
    }
    
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
